<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@ include file="/WEB-INF/adminui/include/css.jsp" %>
<title>种植作业列表</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
	<div class="row">
		<div class="col-sm-2" style="width:20%">
			<div class="ibox ibox-body">
				<div class="ibox-title">
					<h5>选择地块</h5>
				</div>
				<div class="ibox-content">
					<div id="jstree"></div>
				</div>
			</div>
		</div>
		<div class="col-sm-10" style="width:78%">
			<div class="ibox">
				<div class="ibox-body">
					<div class="fixed-table-toolbar">
						<div id="toolbar" class="columns pull-left">
							<qx:perm code="prorecord_ZZ_ADD">
							<button type="button" class="btn btn-primary" onclick="add()" uilist-hide="PARK">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加
							</button>
							</qx:perm>
						</div>
						<div class="columns pull-right" style="margin-left:5px;">
							<button class="btn btn-success" onclick="doexport()">导出Excel</button>
						</div>
						<div class="columns pull-right">
							<button class="btn btn-success" onclick="UiList.loadTable()">查询</button>
						</div>
						<div class="columns pull-right nopadding" style="width:150px;">
							<input id="end" type="text" class="laydate-icon form-control" placeholder="结束日期">
						</div>
						<div class="columns pull-right nopadding" style="vertical-align:middle;height:34px;line-height:34px;padding:0 5px;">至</div>
						<div class="columns pull-right nopadding" style="width:150px;">
							<input id="begin" type="text" class="laydate-icon form-control" placeholder="开始日期">
						</div>
					</div>
					<table id="dataTable" data-mobile-responsive="true">
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<%@ include file="/WEB-INF/adminui/include/script.jsp" %>
<script type="text/javascript">
$(function(){
	laydate({ 
		elem: '#begin'
	});
	laydate({ 
		elem: '#end'
	});
	UiList.render({
		treeUrl: '${path}/parkjstree/menudatatype.json?module=prolink&blockType=1',
		tableConfig:{
			url: "${path}/proRecord/listdata.json?plantType=1",
			idfield: 'recordid',
			columns: [
				{checkbox : true},
				{field : 'blockName', title : '地块名称'},
				{field : 'cropName', title : '种植作物'},
				{field : 'linkName', title : '作业环节'},
				{field : 'linkType', title : '环节类型', formatter : function(value, row, index) {
					switch(''+value){
					case '0': return '基本环节';
					case '1': return '播种环节';
					case '2': return '施肥环节';
					case '3': return '植保环节';
					case '4': return '收获环节';
					}
					return ''+value;
				}},
				{field : 'workdate', title : '作业日期', formatter : function(value, row, index) {
					return formatDate(value, 'yyyy-MM-dd');
				}},
				{field : 'workerName', title : '作业人员'},
				{field : 'plantStatus', title : '作物状态', formatter : function(value, row, index) {
					switch(''+value){
					case '0': return '未成熟';
					case '1': return '已成熟';
					}
					return ''+value;
				}},
				{field : 'beginTime', title : '种植日期', formatter : function(value, row, index) {
					return formatDate(value, 'yyyy-MM-dd');
				}},
				{field : 'isCurrent', title : '当前作物', formatter : function(value, row, index) {
					switch(''+value){
					case '0': return '历史作物';
					case '1': return '当前作物';
					}
					return ''+value;
				}},
				{field : 'recordid', title : '操作', align : 'center', formatter : function(value, row, index) {
					var s = '';
					<qx:perm code="prorecord_ZZ_EDIT">
					s += '<a class="btn btn-primary btn-sm" href="javascript:;" title="修改" onclick="edit(\''+value+'\')">修改</a> ';
					</qx:perm>
					<qx:perm code="prorecord_ZZ_DEL">
					s += '<a class="btn btn-danger btn-sm" href="javascript:;" title="删除" onclick="del(\''+value+'\')">删除</a>';
					</qx:perm>
					return s;
				}}
			]
		},
		tableParams: function(){//搜索条件
			return {begin: $("#begin").val(), end: $("#end").val()};
		}
	});
	
});

function add(){
	UiList.open('${path}/proRecord/add.do', '添加种植作业', {full:true});
}
function del(id){
	UiList.open('${path}/proRecord/deleteOne.do?recordid='+id, '删除作业信息.', {width:500, height:320, layer:{maxmin:false}});
}
function edit(id){
	UiList.open('${path}/proRecord/edit.do?recordid='+id, '修改种植作业', {full:true});
}

function doexport(){
	var node = UiList.getSelectedTreeNode();
	var url = "${path}/proRecord/doexport.do?plantType=1&datatype="+node.type+"&leftdata="+node.id;
	url = url + "&begin="+$("#begin").val();
	url = url + "&end="+$("#end").val();
	window.open(url, '_blank');
}

</script>
</body>
</html>